package ua.org.plast.mobileApp.utils;

import android.view.View;
import android.view.ViewGroup;
import ua.org.plast.mobileApp.constants.GuiConstants;

/**
 * Created with IntelliJ IDEA.
 * User: Virus1908
 * Date: 08.09.13
 * Time: 22:46
 */
public class GuiUtils {

    public static void makeSimpleHeight(View view) {
        if (view != null) {
            ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
            if(layoutParams == null){
                layoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            }
            layoutParams.height = Math.round(GuiConstants.simpleHeight);
            view.setLayoutParams(layoutParams);
        }
    }

    public static void makeSimpleWidth(View view) {
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        layoutParams.width = Math.round(GuiConstants.simpleWidth);
        view.setLayoutParams(layoutParams);
    }


    public static void makeSimpleLayoutParams(View view) {
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        if(layoutParams == null){
            layoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        }
        layoutParams.width = Math.round(GuiConstants.simpleWidth);
        layoutParams.height = Math.round(GuiConstants.simpleHeight);
        view.setLayoutParams(layoutParams);
    }
}
